package productions;

import exceptions.ParserException;
import lexico.ErrorTable;
import lexico.SymbolTable;
import lexico.TokenClass;

/**
 * @author heekinho
 */
public class TipoPrimitivoProduction extends AbstractProductionRule {
    /* Muitos dos métodos irão precisar de algo assim: */

    private static TipoPrimitivoProduction instance = new TipoPrimitivoProduction();

    public static TipoPrimitivoProduction getInstance() {
        return instance;
    }

    /**
     * Regra: tipo_primitivo: 'inteiro' | 'real' | 'logico' | 'caractere' | 'string';
     * @return
     * @throws ParserException
     */
    @Override
    public boolean analyze(SymbolTable st, ErrorTable et) throws ParserException {
        return basicTerminalParsing(st);
    }

    @Override
    protected void populateFirst() {
        first.add(TokenClass.KEYWORD_INTEIRO);
        first.add(TokenClass.KEYWORD_REAL);
        first.add(TokenClass.KEYWORD_LOGICO);
        first.add(TokenClass.KEYWORD_CARACTERE);
        first.add(TokenClass.KEYWORD_STRING);
    }

    @Override
    protected void populateFollow() {
        //from tipovariavel follow
        follow.add(TokenClass.DELIMITER_OPENING_SQUARE_BRACKET);
        follow.add(TokenClass.IDENTIFIER);
        follow.add(TokenClass.OPERATOR_ASSIGNMENT);
        follow.add(TokenClass.OPERATOR_INCREMENT);
        follow.add(TokenClass.OPERATOR_DECREMENT);
        follow.add(TokenClass.DELIMITER_COMMA);
        follow.add(TokenClass.DELIMITER_SEMICOLON);
        follow.add(TokenClass.DELIMITER_OPENING_PARENTHESIS);
        follow.add(TokenClass.DELIMITER_OPENING_SQUARE_BRACKET);
        follow.add(TokenClass.IDENTIFIER);
        follow.add(TokenClass.DELIMITER_COMMA);
        
        follow.add(TokenClass.IDENTIFIER);
    }

}
